package com.turing.data.scripts.zjtq.filter

import com.turing.common.util.StringUtils
import com.turing.data.engine.utils.ScriptsUtils
import com.turing.data.vo.out.review.DependParamsVO
import com.turing.data.vo.out.review.TaskElementVO
import com.turing.data.engine.utils.RegexExtract

/**
 * 场景名称：追加提取单
 * 要素名称：管理费
 **/

class ManagementFee_30239_34_filter {

    static List<TaskElementVO.DrawResultVO> doConvert(DependParamsVO dependParams) {
        List<TaskElementVO.DrawResultVO > resultVOs = ScriptsUtils.tryInitResult(dependParams)
        String businessValue = resultVOs.get(0).getBusinessValue()
        if(!StringUtils.isEmpty(businessValue) ){
            return resultVOs
        }

        List<TaskElementVO.DrawResultVO> trueValueSet = new ArrayList<>()
        String REGEX = /(?<=管理费)\d+.\d{2}(?=元)/
        dependParams.JSONTextMap.forEach(
                { childTaskSn, jsonText ->
                    RegexExtract.doRuleExtract(REGEX,childTaskSn, dependParams, jsonText, trueValueSet)
                }
        )

        if(trueValueSet.size() == 0){
            TaskElementVO.DrawResultVO drawResult = new TaskElementVO.DrawResultVO()
            drawResult.text = ""
            trueValueSet.clear()
            trueValueSet.add(drawResult)
        }

        return trueValueSet
    }

}
